package com.strato.deploy.site;

import java.io.File;
import java.io.FileOutputStream;

public class SiteMain {

	public static void main(String[] args) throws Exception {
		File rootDir=detectRootDir();
		String filename="site.xml";
		File xmlFile=new File(rootDir,filename);
		FileOutputStream fos=new FileOutputStream(xmlFile);
		Generator generator=new Generator();
		generator.generate(rootDir, fos);
		fos.flush();
		fos.close();
		System.out.println("Succesfully generated "+xmlFile);
	}

	private static File detectRootDir() {
		String sRootDir=System.getProperty("root.dir");
		if(sRootDir==null){
			String userDir=System.getProperty("user.dir");
			File rootDir=new File(userDir).getParentFile();
			return rootDir;
		}else{
			return new File(sRootDir);
		}
	}

}
